#!/bin/bash
INSTALL_DIR=$(pwd)/gitee_go_agent
JDK_DOWNLOAD_URL="https://talk.gitee.com/agent/jdk-8u251-linux-x64.tar.gz"

# TOKEN=''
WORK_DIR=$(pwd)
JAVA=java
JDK_DIR="${INSTALL_DIR}/jdk4agent"


mkdir -p ${INSTALL_DIR}
mkdir -p ${JDK_DIR}
if [[ ! -d "${INSTALL_DIR}" ]]; then
  echo "install dir [${INSTALL_DIR}] not exit"
  exit 1
fi


# 安装Jdk
function install_jdk() {
	cd ${JDK_DIR}
	pwd
	echo "-------downloading jdk-------"
	curl ${JDK_DOWNLOAD_URL} -o - | tar -zxf - --no-same-owner
	JAVA=${JDK_DIR}/jdk1.8.0_251/bin/java
	echo "-------jdk download success-------"
}

install_jdk

# 检查参数
echo "--------------PARAMS CHECK--------------"
is_empty "${JDK_DOWNLOAD_URL}" "jdk download url"
# is_empty "${TOKEN}" "token"
is_empty "${INSTALL_DIR}" "install-dir"



echo "here"


